core.createLabel = function(aText, aAlign){
    return new core.Label({
        text: aText,
        align: aAlign || 'right'
    });
}

core.Label = function(aParams){
	this.init(aParams);
}

core.extendClass('core.Label', 'core.Box');

core.Label.prototype.init = function(aParams){
	this.xType = 'label';
	this.superCall('init', arguments, aParams);
	
	var d = document.createElement('div');
	$(d).addClass('label');
    if(aParams.cls)
        $(d).addClass(aParams.cls);
	this.div.appendChild(d);
	this.textDiv = d;
	this.minWidth = aParams.minWidth || LABEL_WIDTH;
	this.minHeight = 20;
	$(this.textDiv).css('width', '100%');
	if(!this.params.align)
		this.params.align = 'right';

}

core.Label.prototype.setWidth = function(aWidth){
	this.width = aWidth;
	$(this.div).width(aWidth);
	$(this.textDiv).html(this.params.text);
	this.minHeight = $(this.textDiv).outerHeight();
//	core.log('label::setWidth', this.params.text, aWidth, this.minHeight);
//	if($(this.textDiv).outerWidth()>this.minWidth)
//		this.minWidth = $(this.textDiv).outerWidth();
//	else
//		this.minWidth = LABEL_WIDTH;
}

core.Label.prototype.setText = function(aText){
    this.params.text = aText;
    this.refresh();
}

core.Label.prototype.makeResize = function(aX, aY, aWidth, aHeight){
	$(this.textDiv).html(this.params.text);
	this.alignElement(this.textDiv, $(this.div).innerWidth(), $(this.div).innerHeight());
}
